Skip to content

Add pennyocr input backend (hosted OCR API, stdlib-only) - #751

Open
imiraoui wants to merge 1 commit into
invoice-x:masterfrom
imiraoui:add-pennyocr-input
Open

Add pennyocr input backend (hosted OCR API, stdlib-only)#751
imiraoui wants to merge 1 commit into
invoice-x:masterfrom
imiraoui:add-pennyocr-input

Conversation

@imiraoui

Copy link
Copy Markdown

Adds a new input backend for PennyOCR, a hosted VLM-based OCR API.

Why it fits invoice2data: users without a local OCR stack (no tesseract binary, no GPU for docTR/paddle, no GCS bucket for gvision) get scanned-invoice support with nothing but an env var. Handles scanned PDFs, photos and images; multipage output uses form-feed separators like the pdftotext backend, so existing templates behave identically.

Implementation notes

  • Standard library only (urllib multipart) — zero new dependencies
  • Follows input/__interface__.py: to_text(path, area_details=None, **kwargs), SUPPORTS_AREA = False, is_available() gated on PENNYOCR_API_KEY so the backend self-excludes when unconfigured
  • Registered in INPUT_MODULES as pennyocr; README list updated
  • Unit tests included (tests/test_pennyocr.py, network mocked): registration, availability gating, multipart request shape, error path — all passing

Service details, for transparency: commercial API, $0.75 per 1,000 pages with 100 free pages/month (no card), zero data retention by default. Disclosure: I'm the maintainer of PennyOCR. Happy to adjust anything — naming, error semantics, or moving it behind an extra if you prefer.

🤖 Generated with Claude Code

A stdlib-only input module for the PennyOCR API: uploads the document,
returns plain text with form-feed page separators (matching pdftotext's
convention). No local OCR engine, GPU or system binary needed; availability
is gated on the PENNYOCR_API_KEY env var so it self-excludes when unset.
Includes unit tests with the network mocked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant